<html>
<head>
<script>
function test_alert(){
alert("test");
}
/*works in firefox*/
function addToDivDom(){
var table = buildTable();
var d = parent.document.getElementById("mydiv");
d.appendChild(table);
}
/*works in IE,firefox,but checkbox is 'dead'*/
function addToDivInner(){
var table = buildTable();
var dummy = document.createElement("div");
dummy.appendChild(table);
var d = document.getElementById("mydiv");
d.innerHTML = dummy.innerHTML;
}
function buildTable(){
var t = parent.document.createElement('TABLE');
var tb = parent.document.createElement('TBODY');
var tr = parent.document.createElement('tr');
var td = parent.document.createElement('td');
var cb = parent.document.createElement( 'input' );
t.border="1";
td.appendChild(cb);
tr.appendChild(td);
tb.appendChild(tr);
t.appendChild(tb);
return t;
cb.type = "checkbox";
cb.name = "vlayer";
cb.id = "s_all";
cb.value = "all";
cb.checked = false;
td.appendChild( cb );

tr.appendChild(td);
t.appendChild(tr);
return t;
}
</script>
</head>

<body>
Test
<div id="mydiv">mydiv</div> <button onclick='addToDivDom();' value="click">Add table to DOM</button>
<button onclick='addToDivInner();' value="click">Add table to InnerHTML</button>
</body>
</html>